<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="org.lanqiao.dxzf.entity.ResultBill"%>
<%@page import="org.lanqiao.dxzf.entity.Page"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <link type="text/css" rel="stylesheet" media="all" href="${pageContext.request.contextPath}/css/global.css" />
        <link type="text/css" rel="stylesheet" media="all" href="${pageContext.request.contextPath}/css/global_color.css" /> 
        <script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
        <script language="javascript" type="text/javascript">
        
        function goPage(page){
        	location.href="bill_list.do?currentPage="+page;
        	}
        function getBillByCon() {
        	var url = "bill_list.do";
        	var cidcard = document.getElementById("cidcard");
        	var fin_account = document.getElementById("fin_account");
        	var cname = document.getElementById("cname");
        	var data = {"cidcard":cidcard,
        				"fin_account":fin_account,
        				"cname",cname
        				};
        	$.ajax({
        		  type: 'POST',
        		  url: url,
        		  data: data,
        		  dataType: "json",
        		  success: function(data){
        			  
        		  },
        		  
        	});
    		$("#billForm").attr("action","${pageContext.request.contextPath }/bill/search.action");
    		$("#billForm").submit();
        } 
      	/* //跳转到item
    	function item(id) {
    		$("#hiddenService").attr("value", id);
    		$("#billForm").submit();
    	} */
      
            //写入下拉框中的年份和月份
            function initialYearAndMonth() {
                //写入最近3年
                var yearObj = document.getElementById("selYears");
                var year = (new Date()).getFullYear();
                for (var i = 0; i <= 2; i++) {
                    var opObj = new Option(year - i, year - i);
                    yearObj.options[i] = opObj;
                }
                //写入 12 月
                var monthObj = document.getElementById("selMonths");
                var opObj = new Option("全部", "全部");
                monthObj.options[0] = opObj;
                for (var i = 1; i <= 12; i++) {
                    var opObj = new Option(i, i);
                    monthObj.options[i] = opObj;
                }
            }
        </script>
    </head>
    <body onload="initialYearAndMonth();">
        <!--Logo区域开始-->
        <%@include file="../include/header.jsp"%>
        <!--导航区域结束-->
        <!--主要区域开始-->
        <div id="main">
			<!--查询-->
			<form action="bill_list.do" method="post">
			<div class="search_add">
				<input type="hidden" id="hiddenService" name="bid" value="-1" />
				<div>
					身份证：<input type="text" id="cidcard" name="cidcard" class="text_search"  />
				</div>
				<div>
					账务账号：<input type="text" id="fin_account" name="fin_account" class="width100 text_search"  />
				</div>
				<div>
					姓名：<input type="text" id="cname" name="cname" class="width70 text_search" />
				</div>
				<div>
					<select class="select_search" id="selYears" name="year">
					</select> 年 <select class="select_search" id="selMonths" name="b_month">
					</select> 月
				</div>
				<div>
					<input type="submit" value="搜索" class="btn_search" onclick="getBillByCon();" />
				</div>
				
			</div>  
			</form>
                <!--数据区域：用表格展示数据-->     
                <div id="data">            
                    <table id="datalist">
                    <tr>
                        <th class="width50">账单ID</th>
                        <th class="width70">姓名</th>
                        <th class="width150">身份证</th>
                        <th class="width150">账务账号</th>
                        <th>费用</th>
                        <th class="width100">月份</th>
                        <th class="width100">支付方式</th>
                        <th class="width100">支付状态</th>                                                        
                        <th class="width50"></th>
                    </tr>
                    <c:forEach items = "${paging.dataList}" var="bl">
                    	<tr>
                    	<td>${bl.bid}</td>
                    	<td>${bl.cname}</td>
                    	<td>${bl.cidcard}</td>
                    	<td>${bl.fin_account}</td>
                    	<td>${bl.b_price}</td>
                    	<td>${bl.b_month}</td>
                    	<td>${bl.pay_way}</td>
                    	<td>${bl.pay_status}</td>
                    	<td><a href="${pageContext.request.contextPath }/bill_item.do?bid=${bl.bid}"  title="账单明细">明细</a></td>
                    	</tr>  
                    </c:forEach>
                </table>
                
                <p>业务说明：<br />
                1、设计支付方式和支付状态，为用户自服务中的支付功能预留；<br />
                2、只查询近 3 年的账单，即当前年和前两年，如2013/2012/2011；<br />
                3、年和月的数据由 js 代码自动生成；<br />
                4、由数据库中的ｊｏｂ每月的月底定时计算账单数据。</p>
                </div>                    
                <!--分页-->
                <div id="pages"> 
                <div style="text-align:center; margin-top:40px" id="venderfen">
				        当前第${paging.currentPage }页/共${paging.totalPage }页
				        <c:choose>
				            <c:when test="${paging.currentPage==1&&paging.totalPage==0}">
				
				            </c:when>
				            <c:when test="${paging.currentPage==1&&paging.totalPage==1}">
				
				            </c:when>
				            <c:when test="${paging.currentPage==2&&paging.totalPage==2}">
				                <input type="button" value="首页" onclick="goPage(1)" />
				                <input type="button" value="上一页"
				                    onclick="goPage(${paging.currentPage-1})" />
				            </c:when>
				            <c:when test="${paging.currentPage==1 }">
				            <input type="button" value="上一页" >
				                <input type="button" value="下一页"
				                    onclick="goPage(${paging.currentPage+1})" />
				                <input type="button" value="末页"
				                    onclick="goPage(${paging.totalPage})" />
				            </c:when>
				            <c:when test="${paging.currentPage==paging.totalPage }">
				                <input type="button" value="首页" onclick="goPage(1)" />
				                <input type="button" value="上一页"
				                    onclick="goPage(${paging.currentPage-1})" />
				            </c:when>
				            <c:otherwise>
				                <input type="button" value="首页" onclick="goPage(1)" />
				                <input type="button" value="上一页"
				                    onclick="goPage(${paging.currentPage-1})" />
				                <input type="button" value="下一页"
				                    onclick="goPage(${paging.currentPage+1})" />
				                <input type="button" value="末页"
				                    onclick="goPage(${paging.totalPage})" />
				            </c:otherwise>
				        </c:choose>
			
                </div> 
		</form>
	</div>
        <!--主要区域结束-->
        <div id="footer">
            
           
        </div>
        <script type="text/javascript" language="javascript">
        //根据权限显示信息
        var listPrivs = "${sessionScope.listPrivs}";
        for(var p of listPrivs){
        if(p=="1")  {document.getElementById("p1").style.display="block";}
        if(p=="2")  {document.getElementById("p2").style.display="block";}
        if(p=="3")	{document.getElementById("p3").style.display="block";}
        if(p=="4")	{document.getElementById("p4").style.display="block";}
        if(p=="5")	{document.getElementById("p5").style.display="block";}
        if(p=="6")	{document.getElementById("p6").style.display="block";}
        if(p=="7")	{document.getElementById("p7").style.display="block";}
        }
        </script>
    </body>
</html>
